import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# 保存图片
figure = plt.figure()# 1.生成figure对象
x = np.linspace(0, 10, 10)
plt.plot(x, 0.5 * x, label='slow')
plt.plot(x, x, label='normal')
plt.plot(x, 2 * x, label='fast')
plt.legend(loc='center left')
plt.legend(loc=(0, 1), ncol=3)  # (0,1)是相对坐标
figure.savefig(fname='./legend.jpg', dpi=500)# 2.保存图像
plt.show()
